<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--+----|----+----|----+----|----+----|----+----|----+----|----+----|----+---->
<HTML>

<HEAD>
 <TITLE>gtkedit - a Notepad clone</TITLE>
</HEAD>

<BODY>
<TABLE ID="header" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR><TD CLASS="header">Gtkedit - A notepad clone based on GTK+</TD></TR>
</TABLE>
<TABLE ID="content" BORDER="" CELLPADDING="" CELLSPACING="">
</TABLE>
<HR>
<H2>Introduction</H2>
<H3>Why another editor? Don't we have enough already?</H3>
<P>Well, yes, indeed. There are quite a lot of different - and not so different -
editors one can download from the Internet. Anyway...</P>
<OL><LI>I wanted a simple project to try GUI programming in Unix.</LI>
<LI>I have an old machine (Pentium 166 MHz, 32 MB RAM) with Slackware Linux 9.0.
This machine runs Xfce 3.8, based on GTK+ 1.2.</LI>
<LI>There's no decent GUI editor for this machine. All are too slow, too bloated
or too ugly.</LI>
</OL>
<P>OK, In fact I did found an editor that works fine. It's called gnotepad+, but
it too takes too long to load (about 2 seconds) in this old machine. There's 
plenty of room for improvements here, I thought.</P>
<P>And so gtkedit begun. I only wanted the most basic editing features: cut, 
copy, paste, basic undo/redo... nothing fancy. The obvious model to copy was, of
course, Notepad.</P>
<H2>What is it ?</H2>
<P>Gtkedit is a simple editor, written using the GTK+ 1.2 toolkit. It aims to 
be (in that order) light, useful and simple (source code-wise).</P>
<UL>
<LI>Binary weight less that 30 KB.</LI>
<LI>Takes less than half a second to start in the development machine.</LI>
<LI>Has nearly all the features of Windows 2000' Notepad (only printing and help 
are missing).</LI>
<LI>The C source code is a single file, about 1400 lines long. No need to 
use a configure script or even a makefile.</LI>
</UL>
<P>Being a simple project, it also can serve as a real world GTK+ tutorial.</P>
<H2>Compiling and running</H2>
<P>To compile the source, issue the following command from a terminal window:</P>
<PRE>	gcc $(gtk-config --cflags --libs) -O -o gtkedit gtkedit.c</PRE>
<P>I assumed you use GNU bash. If you use any other shell, use this instead:</P>
<PRE>	gcc `gtk-config --cflags --libs` -O -o gtkedit gtkedit.c</PRE>
<P>(Beware of the back-quotes (`), as they are not the same as single quotes 
(') if you happen to be a Unix shell).</P>
<P>Once the compilation finishes you can start the program with the command:</P>
<PRE>	./gtkedit</PRE>
<P>This opens the editor with a blank unnamed file. You can add the name of a 
file to have it loaded, if you wish. Alternatively you can use the file manager 
to drag file over the editor window.</P>
<H2>Using the editor</H2>
<P>gtkedit is very simple to use. It understands the basic common shortcut 
keys, like &lt;Ctrl&gt;C for copy. You will find them listed next to each menu 
item.</P>
<P>Very basic undo/redo capabilities are provided, because the editor can only
undo the very last text insertion or removal.</P>
<P>You can find and replace text, and there is a menu option that will allow you
to quickly go to any particular line, which is handy if one is writting a 
program and wants locate an error line.</P>
<P>Finally, you can change the font used for text display, or toggle the 
wrapping of long lines. These settings are lost when the program closes, 
though.</P>
<H2>Configuring gtkedit</H2>
<P>On start-up, gtkedit looks for a file named <TT>.gtkeditrc</TT> on your 
home directory. This is a standard GTK+ configuration file, and allows you to 
configure much of the editor look. I will only show you how to change the 
default font.</P>
<P>Create the <TT>.gtkeditrc</TT> file with the following contents:</P>
<PRE>
style "text-widget" {
       font = "-*-*-medium-r-*--*-120-*-*-m-*-iso8859-1"
}
widget "*.gtkedit-text" style "text-widget"
</PRE>
This will instruct GTK+ to use a monospaced (fixed width) font of size 12 for
the editor. To try another font open the font selection dialog in the editor,
select the font you want, then change to the "Font Information" tab. There you 
will find the line you have to put in the configuration file to use this font 
by default.
</BODY>
</HTML>
